
package com.android.matmanual;

import android.view.KeyEvent;

public class TestControl {
	static final int NORMAL_STATE = 0;
	static final int AUTO_STATE = 1; 
	static final int DO_NOTHING = 0;
	static final int EXIT = 1;
	static final int TRUE_RESULT = 2;
	static final int FALSE_RESULT = 3;
	static int cur_state = 0;
	static int cur_test = -1;
	static final String test_list[] = {
			"android.intent.action.VersionTest",
			"android.intent.action.RFTest", 
			"android.intent.action.ReceiverSdcardMicAutoTest",
			"android.intent.action.SdcardTest",
			"android.intent.action.RTCTest",
			"android.intent.action.KeypadTest",
			"android.intent.action.VibratorTest",
			"android.intent.action.ScreenDeadPointTest",
			"android.intent.action.LCDTest",
			"android.intent.action.SpeakerTest",
			"android.intent.action.ChargingTest",
			"android.intent.action.FMAutoTest",
			"android.intent.action.HeadsetTest",
			"android.intent.action.Touch_Test",
			"android.intent.action.MultipleTPTest",
			"android.intent.action.GravityTest",
			"android.intent.action.WifiTest",
			"android.intent.action.FrontCameraTest",
			"android.intent.action.CameraTest",
			"android.intent.action.BluetoothTest",
			"android.intent.action.SimTest",
			"android.intent.action.GpsTest",
			"android.intent.action.ProximityTest",
			"android.intent.action.LightTest",
			"android.intent.action.MagneticFieldTest",
			"android.intent.action.FlashLightTest",
			//"android.intent.action.OFNTest",
			//"android.intent.action.LEDTest",
			//"android.intent.action.KeyLedTest",
	};
	static int name_list[] = {
		R.string.bulid_number,
		R.string.rf_test,
		R.string.receive_mic,
		R.string.sdcard,
		R.string.rtctest,					
		R.string.keypad,
		R.string.vibrator,
		R.string.screen_dead_point,
		R.string.lcd,
		R.string.speaker,
		R.string.battery,					
		R.string.fm_radio,
		R.string.headset,
		R.string.touch_screen,
		R.string.multipoint_test,
		R.string.gsensor,
		R.string.wifi,
		R.string.front_camera,
		R.string.camera,
		R.string.bluetooth,
		R.string.sim_test,
		R.string.gps_test,	
		R.string.proximity_test,
		R.string.light_test,
		R.string.magnetic_field_test,
		R.string.flashlight_test,    
		//R.string.exit
	};
	static boolean result_list[] = new boolean[name_list.length];
	
	static void Init(int state){
		cur_state = 0;
		cur_test = 0;
		cur_state = state;
		for (int i = 0; i < name_list.length; i++) {
			result_list[i] = false;
		}
	}
	
	static int GetKeyEvent(int key_code) {
		if (NORMAL_STATE == cur_state) {
			if (KeyEvent.KEYCODE_BACK == key_code) {
				return EXIT;
			}
		} else if (AUTO_STATE == cur_state) {
			if (KeyEvent.KEYCODE_VOLUME_UP == key_code) {
				return FALSE_RESULT;
			} else if (KeyEvent.KEYCODE_VOLUME_DOWN == key_code) {
				return TRUE_RESULT;
			}
		}
		return DO_NOTHING;
	}
	
	static String GetNextTest() {
		if (cur_test < test_list.length-1) {
			cur_test++;
			return test_list[cur_test];
		}
		return null;
	}
	
	static void SetCurResult(boolean b_result) {
		result_list[cur_test] = b_result;
	}
	
	static boolean IsAuto() {
		if (AUTO_STATE == cur_state)
			return true;
		else
			return false;
	}
}
		 